/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Comparar.java
 *
 * Created on 24/11/2011, 11:52:14
 */

package ar.lucas.controlgasto.comparar;

import ar.lucas.controlgasto.dao.PersonaDAO;
import ar.lucas.controlgasto.resources.Consultas;
import ar.lucas.controlgasto.statgraphs.drawBarGraphs;
import ar.lucas.controlgasto.utils.ReloadCombo;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormatSymbols;
import javax.swing.Timer;

/**
 *
 * @author lucmussi
 */
public class CompararMes extends javax.swing.JDialog {
        Timer blinkTimer;
        boolean isBlinking = false;
    /** Creates new form Comparar */
    public CompararMes(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    class Blinker implements ActionListener{
        boolean on=false;
        private Double diferencia;

        public Blinker(Double incdiferencia){
            diferencia = incdiferencia;
        }

        public void actionPerformed(ActionEvent e) {
            if(diferencia > 0){
                label_deficit_superav.setForeground( on ? Color.GREEN : null);
                on = !on;
            }
            else{
                label_deficit_superav.setForeground( on ? Color.RED : null);
                on = !on;
            }

        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        myModel = new javax.swing.DefaultListModel();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        comboPersonas = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        selMesPrimero = new com.toedter.calendar.JMonthChooser();
        jLabel3 = new javax.swing.JLabel();
        selMesSegundo = new com.toedter.calendar.JMonthChooser();
        selAnioPrimero = new com.toedter.calendar.JYearChooser();
        selAnioSegundo = new com.toedter.calendar.JYearChooser();
        panel_result_comparacion = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        txt_mesPrimero = new javax.swing.JTextField();
        txt_mesSegundo = new javax.swing.JTextField();
        txt_gastoMesPrimero = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txt_gastoMesSegundo = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txt_diferenciaGasto = new javax.swing.JTextField();
        label_deficit_superav = new javax.swing.JLabel();
        txt_diferencia_porcentual = new javax.swing.JTextField();
        panel_compara_grafico = new javax.swing.JTabbedPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(controlgasto.ControlGastoApp.class).getContext().getResourceMap(CompararMes.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel2.border.title"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        comboPersonas.setName("comboPersonas"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        selMesPrimero.setName("selMesPrimero"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        selMesSegundo.setName("selMesSegundo"); // NOI18N

        selAnioPrimero.setName("selAnioPrimero"); // NOI18N

        selAnioSegundo.setName("selAnioSegundo"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(116, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(114, 114, 114))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(82, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(selMesSegundo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(selMesPrimero, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(selAnioPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(selAnioSegundo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(75, 75, 75))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboPersonas, 0, 156, Short.MAX_VALUE)
                .addGap(58, 58, 58))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(148, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addGap(144, 144, 144))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboPersonas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(selMesPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(selAnioPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(selMesSegundo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(selAnioSegundo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(48, 48, 48))
        );

        ReloadCombo.llenarComboPersonas(comboPersonas);

        panel_result_comparacion.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("panel_result_comparacion.border.title"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); // NOI18N
        panel_result_comparacion.setName("panel_result_comparacion"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        txt_mesPrimero.setEditable(false);
        txt_mesPrimero.setText(resourceMap.getString("txt_mesPrimero.text")); // NOI18N
        txt_mesPrimero.setName("txt_mesPrimero"); // NOI18N

        txt_mesSegundo.setEditable(false);
        txt_mesSegundo.setText(resourceMap.getString("txt_mesSegundo.text")); // NOI18N
        txt_mesSegundo.setName("txt_mesSegundo"); // NOI18N

        txt_gastoMesPrimero.setEditable(false);
        txt_gastoMesPrimero.setName("txt_gastoMesPrimero"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        txt_gastoMesSegundo.setEditable(false);
        txt_gastoMesSegundo.setName("txt_gastoMesSegundo"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        txt_diferenciaGasto.setEditable(false);
        txt_diferenciaGasto.setName("txt_diferenciaGasto"); // NOI18N

        label_deficit_superav.setFont(resourceMap.getFont("label_deficit_superav.font")); // NOI18N
        label_deficit_superav.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_deficit_superav.setText(resourceMap.getString("label_deficit_superav.text")); // NOI18N
        label_deficit_superav.setName("label_deficit_superav"); // NOI18N
        label_deficit_superav.setOpaque(true);

        txt_diferencia_porcentual.setEditable(false);
        txt_diferencia_porcentual.setText(resourceMap.getString("txt_diferencia_porcentual.text")); // NOI18N
        txt_diferencia_porcentual.setName("txt_diferencia_porcentual"); // NOI18N

        javax.swing.GroupLayout panel_result_comparacionLayout = new javax.swing.GroupLayout(panel_result_comparacion);
        panel_result_comparacion.setLayout(panel_result_comparacionLayout);
        panel_result_comparacionLayout.setHorizontalGroup(
            panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txt_mesSegundo)
                            .addComponent(txt_mesPrimero, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
                        .addGap(43, 43, 43)
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txt_gastoMesSegundo))
                            .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txt_gastoMesPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel_result_comparacionLayout.createSequentialGroup()
                                .addGap(115, 115, 115)
                                .addComponent(label_deficit_superav, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel_result_comparacionLayout.createSequentialGroup()
                                .addGap(54, 54, 54)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txt_diferenciaGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_diferencia_porcentual, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(31, Short.MAX_VALUE))
        );
        panel_result_comparacionLayout.setVerticalGroup(
            panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(txt_gastoMesPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26)
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txt_gastoMesSegundo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8)))
                    .addGroup(panel_result_comparacionLayout.createSequentialGroup()
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txt_mesPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addGap(26, 26, 26)
                        .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(txt_mesSegundo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(46, 46, 46)
                .addGroup(panel_result_comparacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txt_diferenciaGasto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_diferencia_porcentual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(label_deficit_superav, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(58, Short.MAX_VALUE))
        );

        panel_compara_grafico.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("panel_compara_grafico.border.title"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); // NOI18N
        panel_compara_grafico.setName("panel_compara_grafico"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panel_result_comparacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(panel_compara_grafico, javax.swing.GroupLayout.DEFAULT_SIZE, 719, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(panel_compara_grafico, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel_result_comparacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if(isBlinking){
            if(blinkTimer.isRunning()){
                blinkTimer.stop();
            }
        }
        PersonaDAO persona = (PersonaDAO) comboPersonas.getSelectedItem();
        Integer id_persona = persona.getId_persona();
        Integer primerMes = selMesPrimero.getMonth()+1;
        Integer segundoMes = selMesSegundo.getMonth()+1;
        Double gastoPrimerMes = Consultas.buscarTotalMes(id_persona, primerMes,selAnioPrimero.getYear());
        Double gastoSegundoMes = Consultas.buscarTotalMes(id_persona, segundoMes, selAnioSegundo.getYear());
        String[] meses = new DateFormatSymbols().getMonths();
        txt_mesPrimero.setText(meses[selMesPrimero.getMonth()].substring(0,1).toUpperCase()+meses[selMesPrimero.getMonth()].substring(1)+" de "+selAnioPrimero.getYear());
        txt_mesSegundo.setText(meses[selMesSegundo.getMonth()].substring(0,1).toUpperCase()+meses[selMesSegundo.getMonth()].substring(1)+" de "+selAnioSegundo.getYear());
        txt_gastoMesPrimero.setText(gastoPrimerMes.toString());
        txt_gastoMesSegundo.setText(gastoSegundoMes.toString());
        Double diferencia = gastoPrimerMes - gastoSegundoMes;
        diferencia = Math.round(diferencia*Math.pow(10,2))/Math.pow(10,2);
        txt_diferenciaGasto.setText(diferencia.toString());
        if(diferencia > 0){
            txt_diferenciaGasto.setForeground(Color.green);
            blinkTimer = new Timer(500, new Blinker(diferencia));
            blinkTimer.start();
            isBlinking = true;
            label_deficit_superav.setText("Superávit");
            txt_diferencia_porcentual.setForeground(Color.green);
        } else if (diferencia == 0){
            label_deficit_superav.setText("");
            txt_diferenciaGasto.setForeground(null);
            txt_diferencia_porcentual.setForeground(Color.black);
            label_deficit_superav.setForeground(Color.black);
            label_deficit_superav.setText("No existe Diferencia");
        }
        else{
            blinkTimer = new Timer(500, new Blinker(diferencia));
            blinkTimer.start();
            isBlinking = true;
            txt_diferenciaGasto.setForeground(Color.red);
            label_deficit_superav.setText("Déficit");
            txt_diferencia_porcentual.setForeground(Color.red);
        }
        double diferencia_porcentual = ((gastoSegundoMes/gastoPrimerMes)-1)*100;
        /*if(gastoPrimerMes > gastoSegundoMes){
            diferencia_porcentual = 100 * gastoSegundoMes;
        }
        else{
            diferencia_porcentual = (100 * (gastoSegundoMes-gastoPrimerMes)/gastoPrimerMes);
        }*/
        int dif_pcnt_entera = (int) diferencia_porcentual;
        txt_diferencia_porcentual.setText(String.valueOf(dif_pcnt_entera)+"%");
        panel_compara_grafico.removeAll();
        panel_compara_grafico.add("Comparación",new drawBarGraphs().genBarGraph(id_persona, primerMes, selAnioPrimero.getYear(), segundoMes, selAnioSegundo.getYear()));
    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox comboPersonas;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel label_deficit_superav;
    private javax.swing.DefaultListModel myModel;
    private javax.swing.JTabbedPane panel_compara_grafico;
    private javax.swing.JPanel panel_result_comparacion;
    private com.toedter.calendar.JYearChooser selAnioPrimero;
    private com.toedter.calendar.JYearChooser selAnioSegundo;
    private com.toedter.calendar.JMonthChooser selMesPrimero;
    private com.toedter.calendar.JMonthChooser selMesSegundo;
    private javax.swing.JTextField txt_diferenciaGasto;
    private javax.swing.JTextField txt_diferencia_porcentual;
    private javax.swing.JTextField txt_gastoMesPrimero;
    private javax.swing.JTextField txt_gastoMesSegundo;
    private javax.swing.JTextField txt_mesPrimero;
    private javax.swing.JTextField txt_mesSegundo;
    // End of variables declaration//GEN-END:variables

}